using System;

using Pegasus.Diagnostics;

namespace Pegasus.Workflow.Service
{
	/// <summary>
	/// Throw by the persistence service when the workflow is locked by someone else and can not be loaded.
	/// </summary>
	[Serializable]
	public class WorkflowLockedException : WorkflowException
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="T:WorkflowLockedException"/> class.
		/// </summary>
		/// <param name="workflowId">The workflow id.</param>
		public WorkflowLockedException( int workflowId ) :
			base( "Workflow {0} is locked by another process and can not be loaded at this time.", workflowId )
		{
			// Check Parameters
			ParamCode.AssertRange( workflowId, 1, int.MaxValue, "workflowId" );
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="T:WorkflowLockedException"/> class.
		/// </summary>
		/// <param name="workflowId">The workflow id.</param>
		/// <param name="message">The message.</param>
		public WorkflowLockedException( int workflowId, string message ) :
			base( "Workflow {0} {1}", workflowId, message )
		{
			// Check Parameters
			ParamCode.AssertRange( workflowId, 1, int.MaxValue, "workflowId" );
		}
	}
}
